//
//  SectionView.m
//  IT爱好者
//
//  Created by dllo on 15/10/15.
//  Copyright © 2015年 Fan. All rights reserved.
//

#import "SectionView.h"
#import "Header.h"
#import "UIImageView+WebCache.h"
@implementation SectionView


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:1];
        [self creatViews];
    }
    return self;
}


- (void)creatViews
{
    _imageViewLeft = [[UIImageView alloc]initWithFrame:CGRectMake(15 * FitWidth, 15 * FitHeight, 50*FitWidth, 50*FitHeight)];
    //_imageViewLeft.backgroundColor = [UIColor redColor];
    [self addSubview:_imageViewLeft];
    
    _nameL = [[UILabel alloc]initWithFrame:CGRectMake(_imageViewLeft.frame.origin.x + _imageViewLeft.frame.size.width + 10 * FitWidth, _imageViewLeft.frame.origin.y, 150 * FitWidth, 20 * FitHeight)];
    //_nameL.backgroundColor = [UIColor greenColor];
    _nameL.textColor = contenttextColor;
    _nameL.font = contentTextSize;
    [self addSubview:_nameL];
    
    _introL = [[UILabel alloc]initWithFrame:CGRectMake(_nameL.frame.origin.x, _nameL.frame.origin.y + _nameL.frame.size.height + 10 * FitHeight, 200 * FitWidth, _nameL.frame.size.height)];
    _introL.textColor = [UIColor colorWithRed:0.71 green:0.71 blue:0.71 alpha:1];
    _introL.font = contentTextSize;
    [self addSubview:_introL];
    
    _imageViewRight = [[UIImageView alloc]initWithFrame:CGRectMake(self.frame.size.width - 15 * FitWidth - 15 * FitWidth, self.frame.size.height / 3, 15 * FitWidth, 20 * FitHeight)];
    _imageViewRight.image = [UIImage imageNamed:@"iconfont-youjianhao"];
    [self addSubview:_imageViewRight];
    
    
}

-(void)setSLModel:(SectionListModel *)SLModel
{
    if (_SLModel != SLModel) {
        _SLModel = SLModel;
    }
    [_imageViewLeft sd_setImageWithURL:[NSURL URLWithString:SLModel.pic]];
    _nameL.text = SLModel.name;
    _introL.text = SLModel.intro;
    
    if ([[NSUserDefaults standardUserDefaults]boolForKey:@"nightIsOn"]) {
        _nameL.textColor = contenttextColor;
        _nameL.backgroundColor = BackgroundColor;
        _introL.backgroundColor = BackgroundColor;
        self.backgroundColor = BackgroundColor;
    }
}






























/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
